package interfaz;

import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
/*
 * iText.java
 *
 * Created on 22 de febrero de 2008, 18:08
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

/**
 *
 * @author victor
 */
public class iText extends iWidget {
    private String text;
    private Font font;
    private Color color;
    private int maxChars = 15;
    
    
    /** Creates a new instance of iText */
    public iText(int x, int y) {
        super(x,y);
    }
    
    public void setMaxChars(int max) {
        this.maxChars = max;
    }
    
    public int getMaxChars() {
        return this.maxChars;
    }
    
    public void setText(String text) {
        this.text = text;
    }
    
    public String getText() {
        return this.text;
    }
    
    public void setFont(Font font) {
        this.font = font;
    }
    
    public Font getFont() {
        return this.font;
    }
    
    public void setColor(Color color) {
        this.color = color;
    }
    
    public Color getColor() {
        return this.color;
    }
    
    public void paint(Graphics g) {
        String textToDraw;
        if (getText().length() > getMaxChars()) { // tamanho supera maximo
            textToDraw = getText().substring(0,getMaxChars());
            textToDraw = textToDraw.concat("...");
        }
        else textToDraw = getText();
        g.setColor(getColor());
        g.setFont(getFont());
        g.drawString(textToDraw,x,y);
    }
}
